<?php
require_once 'db2.php';
class Works extends db2{     //thua ke
    public $query;
    public $table_name;
    public function selectworks(){ //phuong thuc
        $this->getconnection();    
        $query = 'SELECT * FROM works LIMIT 0,10';
        $works = $this->query($query);
        return $works;
    }
    public function select($page=null){
        $this->getconnection(); 
        $rows=array();
        $begin=($page-1)*PAGE;
        $query="SELECT * FROM $this->table_name limit ".$begin.",".PAGE;
        $result=mysql_query($query);
        while ($row=  mysql_fetch_assoc($result))
         $rows[]=$row;
        return $rows;
    } 
     public  function insert($keywords){
        $this->getconnection(); 
        $query="INSERT $this->table_name (id, name) values($words[0])";
    } 
    
     public  function countWords(){
        $this->getconnection(); 
        $rows=array();
        $query="SELECT * FROM $this->table_name";
        $result=mysql_query($query);
        while ($row=  mysql_fetch_assoc($result))
         $rows[]=$row;
        return count($rows);
    } 
    
}
?>